package com.autohelper.app;


import com.autohelper.app.tcp.client.NettyClient;

public class ServiceHolder {

    public static final ServiceHolder INSTANCE = new ServiceHolder();

    private NettyClient nettyClient;
    private FloatingStepView floatingStepView;
    private ActionOperator actionOperator;
    private ScreenCaptureManager screenCaptureManager = new ScreenCaptureManager();

    private String serverIp;
    private String deviceNo;

    public void doInit() {
        // 初始化网络客户端
        nettyClient = new NettyClient(serverIp, 8880, deviceNo);
        nettyClient.start();
        floatingStepView = new FloatingStepView(AutoAccessibilityService.INSTANCE);
        actionOperator = new ActionOperator(AutoAccessibilityService.INSTANCE);
    }

    public void doDestroy() {
        if (nettyClient != null) {
            nettyClient.stop();
        }
        if (floatingStepView != null) {
            floatingStepView.hide();
        }
        if (floatingStepView != null) {
            floatingStepView.hide();
        }
    }

    public NettyClient getNettyClient() {
        return nettyClient;
    }

    public FloatingStepView getFloatingStepView() {
        return floatingStepView;
    }

    public ActionOperator getActionOperator() {
        return actionOperator;
    }

    public ScreenCaptureManager getScreenCaptureManager() {
        return screenCaptureManager;
    }

    public void setServerIp(String serverIp) {
        this.serverIp = serverIp;
    }

    public void setDeviceNo(String deviceNo) {
        this.deviceNo = deviceNo;
    }
}


